package com.wolfsea.launcherdemo
import androidx.recyclerview.widget.RecyclerView
import com.wolfsea.launcherdemo.databinding.BottomContentRvItemBinding

/**
 *@desc  BottomContentRvAdapter
 *@author liuliheng
 *@time 2022/12/22  10:29
 **/
class BottomContentRvAdapter(dataSet:MutableList<BottomLayoutItem>) : BaseRvAdapter<BottomLayoutItem, BottomContentRvItemBinding>(dataSet) {

    override fun getLayoutId(): Int = R.layout.bottom_content_rv_item

    override fun bindData(holder: ViewHolder, dataItem: BottomLayoutItem, position: Int) {
        holder.binding.rvItemTvContent.text = dataItem.content
        val layoutParams = holder.binding.root.layoutParams as RecyclerView.LayoutParams
        layoutParams.bottomMargin =
            if (position == itemCount - 1) holder.binding.root.context.resources.getDimension(R.dimen.dp_10).toInt()
            else 0
        holder.binding.root.layoutParams = layoutParams
        holder.binding.root.setOnClickListener {
            holder.binding.root.context.showToast(dataItem.content)
        }
    }
}